Skip to content

log semantic response diagnostics#315

Closed
ndycode wants to merge 3 commits intofeat/openai-parity-pr6from
feat/openai-parity-pr7
Closed

log semantic response diagnostics#315
ndycode wants to merge 3 commits intofeat/openai-parity-pr6from
feat/openai-parity-pr7

Conversation

@ndycode
Copy link
Owner

@ndycode ndycode commented Mar 22, 2026

Summary

  • log semantic response diagnostics for phase, commentary, final-answer, and reasoning-summary fields
  • keep the diagnostics on the existing logging path without changing the response transport
  • add focused coverage for semantic diagnostic logging

Stack

  • base: #314

note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.

Greptile Summary

adds semantic response diagnostics logging to the sse-to-json conversion path. after parseSseStream assembles the final response, the new logStreamDiagnostics function reads the computed phase, commentary_text, final_answer_text, and reasoning_summary_text fields, truncates each to 400 chars, and emits a "stream-diagnostics" log entry only when at least one semantic field is present. no changes to the response transport.

  • truncateDiagnosticText: safe unknown → string helper with 400-char cap; correctly returns undefined for non-strings and empty strings.
  • logStreamDiagnostics: guarded by LOGGING_ENABLED and isRecord; omitted from the null-response code path; spreads only present fields into the log payload.
  • beforeEach mock clear added to response-handler-logging.test.ts — correct fix that prevents call-count contamination across tests.
  • new test covers the full happy path (phase, commentary, final-answer, reasoning-summary) against a realistic multi-event sse fixture.
  • truncation branch in truncateDiagnosticText has no vitest coverage (strings > 400 chars never exercised).

Confidence Score: 5/5

  • safe to merge — pure additive logging on the happy path, no transport changes, and existing tests are not broken.
  • change is minimal and isolated: two small helper functions, one call site after the null-response guard, and a focused test addition. no concurrency concerns (logging is synchronous and fire-and-forget). no windows filesystem or token-safety risk. the only gap is the untested truncation branch, which is a P2 follow-up.
  • no files require special attention.

Important Files Changed

Filename Overview
lib/request/response-handler.ts adds truncateDiagnosticText and logStreamDiagnostics helpers; called cleanly after the null-response guard in convertSseToJson; no transport impact. truncation branch is untested.
test/response-handler-logging.test.ts adds beforeEach mock clear (good isolation fix) and a full happy-path test covering phase, commentary, final-answer, and reasoning-summary diagnostics. truncation edge case not covered.
test/request-transformer.test.ts cosmetic: removes two blank lines between test cases, no functional change.

Sequence Diagram

sequenceDiagram
    participant caller
    participant convertSseToJson
    participant parseSseStream
    participant logStreamDiagnostics
    participant logRequest

    caller->>convertSseToJson: response (SSE stream), headers
    convertSseToJson->>convertSseToJson: consume stream chunks
    convertSseToJson->>logRequest: "stream-full" { fullContent }
    convertSseToJson->>parseSseStream: fullText
    parseSseStream-->>convertSseToJson: finalResponse (or null)
    alt finalResponse is null
        convertSseToJson-->>caller: raw SSE response (passthrough)
    else finalResponse present
        convertSseToJson->>logStreamDiagnostics: finalResponse
        logStreamDiagnostics->>logStreamDiagnostics: extract phase, commentaryText,\nfinalAnswerText, reasoningSummaryText
        opt any semantic field present
            logStreamDiagnostics->>logRequest: "stream-diagnostics" { responseId, phase, ... }
        end
        convertSseToJson-->>caller: JSON response
    end
Loading

Fix All in Codex

Prompt To Fix All With AI
This is a comment left during a code review.
Path: lib/request/response-handler.ts
Line: 352-357

Comment:
**Missing vitest coverage for truncation branch**

the `trimmed.length > maxLength` branch has no test exercising it. the new test only passes strings well under 400 chars (`"Thinking..."`, `"Done."`, `"Need more context."`), so the slice-and-append path is never hit. given the 80% coverage threshold, it's worth adding a test with a string > 400 chars to verify the truncated output matches expectations and the `...` suffix is appended correctly.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (3): Last reviewed commit: "Merge main into feat/openai-parity-pr7" | Re-trigger Greptile

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 22, 2026

Warning

Rate limit exceeded

@ndycode has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 46 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c3c2f668-69d3-4dd5-9894-464d5bd59b76

📥 Commits

Reviewing files that changed from the base of the PR and between 5f16828 and 14b6cc5.

📒 Files selected for processing (3)
  • lib/request/response-handler.ts
  • test/request-transformer.test.ts
  • test/response-handler-logging.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/openai-parity-pr7
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/openai-parity-pr7

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@ndycode ndycode added the needs-human-review Flagged by automated PR quality screening; maintainer review required. label Mar 22, 2026
@ndycode
Copy link
Owner Author

ndycode commented Mar 22, 2026

@coderabbitai review
@greptile @cubic review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 22, 2026

@ndycode: on it — reviewing the semantic diagnostics logging changes now.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ndycode ndycode force-pushed the feat/openai-parity-pr6 branch from 3c4429f to 5f16828 Compare March 22, 2026 13:43
@ndycode ndycode removed the needs-human-review Flagged by automated PR quality screening; maintainer review required. label Mar 22, 2026
@ndycode
Copy link
Owner Author

ndycode commented Mar 23, 2026

Closing because this work is now included in main via #318 and #319.

@ndycode ndycode closed this Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant